﻿using System.Collections.Generic;
using System.Data.Common;

namespace HundSunDBQryServer
{
    internal class SqlHelp
    {
        internal static List<Dictionary<string, object>> getRecords(DbCommand cmd)
        {
            List<Dictionary<string, object>> redords = new List<Dictionary<string, object>>();
           
            var tReader = cmd.ExecuteReader();
            while (tReader.Read())
            {
                Dictionary<string, object> kv = new Dictionary<string, object>();
                for (int i = 0; i < tReader.FieldCount; i++)
                {
                    kv.Add(tReader.GetName(i), tReader.GetValue(i));
                }
                redords.Add(kv);
            }
            tReader.Close();
            return redords;
        }
    }
}
